<?php
namespace app\index\controller;
use think\Controller;
use think\Db;
class Reg extends Controller
{
    public function index()
    {
       return $this->fetch();
    }
    public function reg()
    {
        $data = [
            "user_phone"=>input('user_phone'),
            "user_pw"=>md5(input('user_pw')),
            "status"=>0,
        ];
        // dump($data);
        // exit;
        $phone = Db::name('user')->where('user_phone',input('user_phone'))->find();
        // dump($res);
        // exit;
        if($phone==null){

            $res = Db::table('user')->insert($data);
                if($res)
                {
                    return $this->success('注册成功','login/index');
                }
                else
                {
                    return $this->error('注册失败');
                }
            
        }else{
            return $this->error('账号已经注册');
        }
    }
}